package com.egg.ylt.presenter.impl;

import com.egg.ylt.Utils.API;
import com.egg.ylt.pojo.AppointmentServeListEntity;
import com.egg.ylt.presenter.IOrderItemPresenter;
import com.egg.ylt.view.IOrderItemView;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.CommonUtils;
import com.yonyou.framework.library.mvp.impl.BasePresenter;
import com.yonyou.framework.library.net.ReqCallBack;
import com.yonyou.framework.library.net.RequestManager;

import java.util.HashMap;

/**
 * Created by sichaoqi on 2018/9/4.
 */

public class OrderItemPresenterImpl extends BasePresenter<IOrderItemView> implements IOrderItemPresenter {

    @Override
    public void getOrderList(String token, String phone, String pageSize, String pageNum, String status) {
        mView.showDialogLoading("数据加载中");
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("token", token);
        hashMap.put("phone", phone);
        hashMap.put("pageSize", pageSize);
        hashMap.put("pageNum", pageNum);
        hashMap.put("status", status);

        RequestManager.getInstance().requestPostByAsyn(API.GET_APPOINTMENT_SERVE_LIST, hashMap,
                new ReqCallBack<AppointmentServeListEntity>() {

                    @Override
                    public void onReqSuccess(AppointmentServeListEntity result) {
                        mView.dismissDialogLoading();
                        mView.setOrderList(result == null ? null : result.getList());
                    }

                    @Override
                    public void onFailure(String result) {
                        mView.dismissDialogLoading();
                        CommonUtils.makeEventToast(mContext, result, false);
                    }

                    @Override
                    public void onReqFailed(ErrorBean error) {
                        mView.dismissDialogLoading();
                        CommonUtils.makeEventToast(mContext, error.getMsg(), false);
                    }
                });
    }
}
